package com.sheepone.util.time.getter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @author Miss.杨
 * @description
 * @since 2025/3/13 - 21:25
 */
public class DateGetter {
    private DateGetter() {
    }

    public static Date fromString(String dateStr, String pattern) throws ParseException {
        return new SimpleDateFormat(pattern).parse(dateStr);
    }

    public static Date plusDays(int n) {
        return plusDays(new Date(), n);
    }

    public static Date plusDays(Date date, int n) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.DATE, n);
        return calendar.getTime();
    }
}
